import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { InboundManageDTO, CreateUpdateInboundManageDTO } from './dto/models';
import { PagedResultDto } from '@abp/ng.core';

@Injectable({
  providedIn: 'root'
})
export class InboundServicesService {
  private apiUrl = '/api/app/inbound-services';

  constructor(private http: HttpClient) { }

  getList(params: any): Observable<PagedResultDto<InboundManageDTO>> {
    return this.http.get<PagedResultDto<InboundManageDTO>>(this.apiUrl, { params });
  }

  get(id: string): Observable<InboundManageDTO> {
    return this.http.get<InboundManageDTO>(`${this.apiUrl}/${id}`);
  }

  create(input: CreateUpdateInboundManageDTO): Observable<InboundManageDTO> {
    return this.http.post<InboundManageDTO>(this.apiUrl, input);
  }

  update(id: string, input: CreateUpdateInboundManageDTO): Observable<InboundManageDTO> {
    return this.http.put<InboundManageDTO>(`${this.apiUrl}/${id}`, input);
  }

  delete(id: string): Observable<void> {
    return this.http.delete<void>(`${this.apiUrl}/${id}`);
  }

  approve(id: string, approvalData: any): Observable<void> {
    return this.http.post<void>(`${this.apiUrl}/${id}/approve`, approvalData);
  }

  exportToExcel(): Observable<Blob> {
    return this.http.post(`${this.apiUrl}/export-to-excel`, {}, { responseType: 'blob' });
  }
} 